package com.documents.common.core.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.documents.common.core.dao.BaseDao;

public abstract class BaseSrv<T,ID extends Serializable> {
	protected BaseDao<T,ID> dao;
	protected JdbcTemplate jdbcTemplate;
	protected static final String decrateString(String string) {
		if (string == null || string.length() == 0)
			return "%";
		return "%" + string + "%";
	}
	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public BaseDao<T, ID> getDao() {
		return dao;
	}

	public void setDao(BaseDao<T, ID> dao) {
		this.dao = dao;
	}

	public void delById(ID id) {
		dao.delById(id);
	}

	public void delete(T obj) {
		dao.delete(obj);
	}

	public boolean exists(String condition, Object[] parameters) {
		return dao.exists(condition, parameters);
	}

	public List<T> find(String condition, Object[] parameters, String sort) {
		return dao.find(condition, parameters, sort);
	}

	public long findTotalCount(String condition, Object[] parameters) {
		return dao.findTotalCount(condition, parameters);
	}

	public T findUnique(String condition, Object[] parameters) {
		return dao.findUnique(condition, parameters);
	}

	public List<T> findWithPaging(String condition, Object[] parameters, String sort,
			int start, int limit) {
		return dao.findWithPaging(condition, parameters, sort, start, limit);
	}

	public T get(ID id) {
		return dao.get(id);
	}

	public T load(ID id) {
		return dao.load(id);
	}

	public void save(T obj) {
		dao.save(obj);
	}

	public void update(T obj) {
		dao.update(obj);
	}
	
	public List<T> findAll() {
		return dao.findAll();
	}

	public void bulkDelByIds(ID[] ids) {
		dao.bulkDelByIds(ids);
	}
	
}
